/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Database;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import oracle.jdbc.pool.OracleDataSource;

/**
 *
 * @author Prasetyawan
 */
public class CreateTableOracle {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        String jdbcUrl = "jdbc:oracle:thin:@localhost:1521:xe";
        String userid = "HR"; 
        String password = "hr"; 

        Connection conn;
        try {
            OracleDataSource ds;
            ds = new OracleDataSource();
            ds.setURL(jdbcUrl);
            conn = ds.getConnection(userid, password);
            System.out.println("Koneksi is OK");
            Statement statement = conn.createStatement();

            String sql = " CREATE table KATEGORI ( KODEKATEGORI VARCHAR2(100) NOT NULL,NAMAKATEGORI VARCHAR2(20) NOT NULL, "
                    + "constraint KATEGORII_PK primary key (KODEKATEGORI) ENABLE)";

            statement.executeUpdate(sql);

        } catch (SQLException e) {
            System.out.println("error :" + e.getMessage());
        }
    }
}
